#ifndef SESSION_H
#define	SESSION_H

#include <stdint.h>
#include "pkcs11.h"
#include "chan.h"

#define	MAX_SESSION_BUF	(64 * 1024 + 512)
#define	CKR_CHAN_READ	(0X100)
#define	CKR_CHAN_WRITE	(0X101)

typedef struct buffer_st
{
	void	*ptr;
	int	len;
	int	size;
}buffer_t;

typedef struct session_st
{
	chan_t	 *chan;
	buffer_t *bf;
}session_t;

typedef void (*pkcs11fun)(void *ctx, uint8_t *in, int inlen, uint8_t *out, int *outlen);

int MSG_RECV_BUFFER_SIZE(CK_SESSION_HANDLE session);
uint8_t *MSG_RECV_BUFFER_START(CK_SESSION_HANDLE session);
uint8_t	*MSG_SEND_BUFFER_START(CK_SESSION_HANDLE session);

int session_send(CK_SESSION_HANDLE session, uint8_t *data, int len); 
int session_recv(CK_SESSION_HANDLE session, uint8_t *buf, int len);


#endif
